a11y: Export the printed value of a scale as the description.
authorBenjamin Otte <otte@redhat.com>
Sat, 25 Jun 2011 17:47:46 +0000 (19:47 +0200)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 5 Jul 2011 20:08:09 +0000 (16:08 -0400)
gtk/a11y/gailscale.c

index 5291d8a0b36d0fba41314fce5b845faed225cf42..de276d592fbd13d8eefa12c5f8f7450bd1909074 100644 (file)
@@ -30,6 +30,7 @@ static void         gail_scale_init              (GailScale      *scale);
 
 static void         gail_scale_real_initialize   (AtkObject      *obj,
                                                   gpointer      data);
+static const char * gail_scale_get_description   (AtkObject     *object);
 static void         gail_scale_notify            (GObject       *obj,
                                                   GParamSpec    *pspec);
 static void         gail_scale_finalize          (GObject        *object);
@@ -91,6 +92,7 @@ gail_scale_class_init (GailScaleClass *klass)
   AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
 
   class->initialize = gail_scale_real_initialize;
+  class->get_description = gail_scale_get_description;
 
   gobject_class->finalize = gail_scale_finalize;
   gobject_class->notify = gail_scale_notify;
@@ -101,6 +103,24 @@ gail_scale_init (GailScale      *scale)
 {
 }
 
+static const char *
+gail_scale_get_description (AtkObject *object)
+{
+  GtkWidget *widget;
+  PangoLayout *layout;
+
+  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (object));
+  if (widget == NULL)
+    /* State is defunct */
+    return NULL;
+
+  layout = gtk_scale_get_layout (GTK_SCALE (widget));
+  if (layout)
+    return pango_layout_get_text (layout);
+
+  return ATK_OBJECT_CLASS (gail_scale_parent_class)->get_description (object);
+}
+
 static void
 gail_scale_real_initialize (AtkObject *obj,
                             gpointer  data)